import { v4 as uuidv4 } from 'uuid';
// 生成一个随机字符串，每次执行不能发生变化，游客身份持久存储
export const getUUID = () => {
  // 先从本地存储获取uuid，如果有返回本地存储的uuid如果没有就重新生成，然后存储
  let uuid_token = localStorage.getItem('UUID_TOKEN');
  if(!uuid_token){
    uuid_token = uuidv4();
    localStorage.setItem('UUID_TOKEN', uuid_token);
  }
  return uuid_token;
}